/*
 * UIStyle.h
 *
 *  Created on: 2010-3-19
 *      Author: Administrator
 */

#ifndef UISTYLE_H_
#define UISTYLE_H_

#include <e32def.h>
#include <GDI.H>
#include <Babitflags.h>

class UIFont
	{
public:
	void CreateFont(const TDesC& fontName,TInt fontsize);
	CFont* GetFont()
	{
		return iFont;
	}
private:
	CFont* iFont;
	};

class UILength
	{
public:
	enum ELengthUnit
		{
		ELU_Unknown = 0,
		ELU_Percent,
		ELU_Pixel,
		ELU_Auto
		};
private:
	TInt iLength;
	ELengthUnit iUnit;
	
public:
	UILength();
	UILength(TInt aVal,ELengthUnit aUnit);
	void SetLength(TInt aVal,ELengthUnit aUnit);
	UILength& operator=(const TDesC& aLength);
	TInt GetLength(TInt aMaxLength=0) const;
	TInt GetUnit() const;
	};

class UISize
	{
private:
	UILength iWidth;
	UILength iHeight;
	
public:
	TInt Width() const
		{
		return iWidth.GetLength();
		}
	
	TInt Height() const
		{
		return iHeight.GetLength();
		}
	
	void SetWidth(TInt aVal)
		{
		if(aVal == -1)
			iWidth.SetLength(0,UILength::ELU_Auto);
		else
			iWidth.SetLength(aVal,UILength::ELU_Pixel);
		}
	
	void SetHeigth(TInt aVal)
		{
		if(aVal == -1)
			iHeight.SetLength(0,UILength::ELU_Auto);
		else
			iHeight.SetLength(aVal,UILength::ELU_Pixel);
		}
	
	TInt GetWidthUnit() const
		{
		return iWidth.GetUnit();
		}
	
	TInt GetHeightUnit() const
		{
		return iHeight.GetUnit();
		}
	};

class UIMargin
	{
public:
	UILength iLeft;
	UILength iTop;
	UILength iRight;
	UILength iBottom;
	
public:
	void AssignL(const TDesC& aMargin);
	TInt GetLeft(TInt aMax = 0) const;
	TInt GetTop(TInt aMax = 0) const;
	TInt GetRight(TInt aMax = 0) const;
	TInt GetBottom(TInt aMax = 0) const;
	};

typedef UIMargin UIPadding;

class UIColor
	{
private:
	TRgb iColor;
	
public:
	UIColor& operator=(const TDesC& aColor);
	TRgb GetColor() const;
	};

class UISingleBorder
	{
public:
	enum EUIBorderStyle
		{
		EBStyle_Solid,
		EBStyle_Dash,
		EBStyle_Dot
		};
	
public:
	UILength iWidth;
	UIColor iColor;
	EUIBorderStyle iBorderStyle;
	
public:
	UISingleBorder& operator=(const TDesC& aDes);
	};

class UIBorder
	{
public:
	enum EBorderSet
		{
		EBS_SetLeft = 0,
		EBS_SetRight,
		EBS_SetTop,
		EBS_SetBottom
		};
public:
	UISingleBorder iBorderL;
	UISingleBorder iBorderT;
	UISingleBorder iBorderR;
	UISingleBorder iBorderB;
	
private:
	TBitFlags8 iMask;
	
public:
	TBool IsSet(EBorderSet aSet);
	void Set(EBorderSet aSet);
	};


class UIStyle
	{
public:
	enum EStylePosition
		{
		ESP_Relative,
		ESP_Absolute
		};
	enum EStyleOverflow
		{
		ESO_Auto,
		ESO_None
		};
public:
	UIStyle();
	virtual ~UIStyle();
	
public:
	UIMargin iMargin;		//Ĭ��Ϊ0
	UIBorder iBorder;		//Ĭ��Ϊ0
	UIPadding iPadding;		//Ĭ��Ϊ0
	UILength iWidth;
	UILength iHeight;
	TInt iLeft;
	TInt iTop;
	EStylePosition iPosition;   //Ĭ��ΪRelative
	EStyleOverflow iOverflow;   //Ĭ�ϲ�overflow
	UIColor iBackgroundColor;
	};

#endif /* UISTYLE_H_ */
